#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

void solve(int s[], int n, int& l, int& r)
{
	int mid = n / 2;
	for (l = 0; l < n; l++)
	{
		if (s[l] == s[mid])
			break;
	}
	for (r = l + 1; r < n; r++)
	{
		if (s[r] != s[mid])
		{
			break;
		}
	}
}

void _MaxCnt(int &mid, int &maxCnt, int a[], int n)
{
	int l, r;
	solve(a, n, l, r);
	int num = n / 2;
	int cnt = r - l;
	if (cnt > maxCnt)
	{
		maxCnt = cnt;
		mid = a[num];
	}
	if (l + 1 > maxCnt)
	{
		_MaxCnt(mid, maxCnt, a, l + 1);
	}
	if (n - r > maxCnt)
	{
		_MaxCnt(mid, maxCnt, a + r, n - r);
	}
}

int main()
{
	FILE* pf = fopen("input.txt", "r");
	int a[16];
	int n;
	fscanf(pf, "%d", &n);
	int j = 0;
	for (int i = 0; i < n; i++)
	{
		int num;
		fscanf(pf, "%d", &num);
		while (num)
		{
			a[j++] = num % 10;
			num /= 10;
		}
	}
	fclose(pf);
	sort(a, a + j);
	int maxCnt = 0;
	int num = 0;
	_MaxCnt(num, maxCnt, a, j);
	cout << num << " " << maxCnt << endl;
	pf = fopen("output.txt", "w");
	fprintf(pf, "mode:%d\nCnt:%d\n", num, maxCnt);
	fclose(pf);
	return 0;
}